﻿using System;
using System.Xml.Serialization;

namespace PVTLibrary
{

    [Serializable]
    [XmlRoot(ElementName:="Component")]
    public class  Unidades
    {
        public string nome; 

        public string area;
        public string distance; 
        public string time; 
        public string volume; 
        public string molar_volume; 
        public string diameter; 
        public string thickness; 
        public string molar_conc; 
        public string mass_conc; 
        public string heat_transf_coeff; 
        public string force; 
        public string accel; 
        public string spec_vol; 
        public string reac_rate; 
        public string velocity; 
        public string foulingfactor;

        public string  molar_enthalpy;
        public string  molar_entropy;

        public string  tdp_idealGasHeatCapacity ;
        public string  tdp_surfaceTension ;
        public string  tdp_thermalConductivityOfLiquid ;
        public string  tdp_thermalConductivityOfVapor ;
        public string  tdp_vaporPressure ;
        public string  tdp_viscosityOfLiquid ;
        public string  tdp_viscosityOfVapor ;

        public string  pdp_boilingPointTemperature ;
        public string  pdp_meltingTemperature ;

        public string  spmp_activity ;
        public string  spmp_activityCoefficient ;
        public string  spmp_compressibility ;
        public string  spmp_compressibilityFactor ;
        public string  spmp_density ;
        public string  spmp_enthalpy ;
        public string  spmp_entropy ;
        public string  spmp_excessEnthalpy ;
        public string  spmp_excessEntropy ;
        public string  spmp_molarflow ;
        public string  spmp_massflow ;
        public string  spmp_molarfraction ;
        public string  spmp_massfraction ;
        public string  spmp_fugacity ;
        public string  spmp_fugacityCoefficient ;
        public string  spmp_heatCapacityCp ;
        public string  spmp_heatCapacityCv ;
        public string  spmp_jouleThomsonCoefficient ;
        public string  spmp_logFugacityCoefficient ;
        public string  spmp_molecularWeight ;
        public string  spmp_pressure ;
        public string  spmp_temperature ;
        public string  spmp_speedOfSound ;
        public string  spmp_thermalConductivity ;
        public string  spmp_viscosity ;
        public string  spmp_cinematic_viscosity ;
        public string  spmp_volumetricFlow ;
        public string  spmp_heatflow ;
        public string  spmp_head ;
        public string  spmp_deltaT ;
        public string  spmp_deltaP ;

        public string  tpmp_kvalue ;
        public string  tpmp_logKvalue ;
        public string  tpmp_surfaceTension ;
    }


    [Serializable]
    public class  UnidadesSI : Unidades
    {
        public UnidadesSI()
        {
            nome = "SistemaSI";

            accel = "m2/s";
            area = "m2";
            diameter = "mm";
            distance = "m";
            force = "N";
            heat_transf_coeff = "W/[m2.K]";
            mass_conc = "kg/m3";
            molar_conc = "mol/m3";
            molar_volume = "m3/kmol";
            reac_rate = "mol/[m3.s]";
            spec_vol = "m3/kg";
            time = "s";
            volume = "m3";
            thickness = "mm";
            molar_enthalpy = "kJ/kmol";
            molar_entropy = "kJ/[kmol.K]";
            velocity = "m/s";
            foulingfactor = "K.m2/W";

            pdp_boilingPointTemperature = "K";
            pdp_meltingTemperature = "K";
            spmp_activity = "Pa";
            spmp_activityCoefficient = "-";
            spmp_compressibility = "Pa-1";
            spmp_compressibilityFactor = "-";
            spmp_density = "kg/m3";
            spmp_enthalpy = "kJ/kg";
            spmp_entropy = "kJ/[kg.K]";
            spmp_excessEnthalpy = "kJ/kg";
            spmp_excessEntropy = "kJ/[kg.K]";
            spmp_fugacity = "Pa";
            spmp_fugacityCoefficient = "-";
            spmp_heatCapacityCp = "kJ/[kg.K]";
            spmp_heatCapacityCv = "kJ/[kg.K]";
            spmp_jouleThomsonCoefficient = "K/Pa";
            spmp_logFugacityCoefficient = "-";
            spmp_massflow = "kg/s";
            spmp_massfraction = "-";
            spmp_molarflow = "mol/s";
            spmp_molarfraction = "-";
            spmp_molecularWeight = "kg/kmol";
            spmp_pressure = "Pa";
            spmp_speedOfSound = "m/s";
            spmp_temperature = "K";
            spmp_thermalConductivity = "W/[m.K]";
            spmp_viscosity = "Pa.s";
            spmp_volumetricFlow = "m3/s";
            spmp_cinematic_viscosity = "m2/s";
            tdp_idealGasHeatCapacity = "kJ/[kg.K]";
            tdp_surfaceTension = "N/m";
            tdp_thermalConductivityOfLiquid = "W/[m.K]";
            tdp_thermalConductivityOfVapor = "W/[m.K]";
            tdp_vaporPressure = "Pa";
            tdp_viscosityOfLiquid = "Pa.s";
            tdp_viscosityOfVapor = "Pa.s";
            tpmp_kvalue = "-";
            tpmp_logKvalue = "-";
            tpmp_surfaceTension = "N/m";
            spmp_heatflow = "kW";
            spmp_head = "m";
            spmp_deltaP = "Pa";
            spmp_deltaT = "K";
        }
    }

    [Serializable]
    public class  UnidadesSI_Deriv1 : Unidades
    {
        public UnidadesSI_Deriv1()
        {
            nome = "Personalizado1BR";

            accel = "m2/s";
            area = "m2";
            diameter = "mm";
            distance = "m";
            force = "N";
            heat_transf_coeff = "W/[m2.K]";
            mass_conc = "kg/m3";
            molar_conc = "kmol/m3";
            molar_volume = "m3/kmol";
            reac_rate = "kmol.[m3.s]";
            spec_vol = "m3/kg";
            time = "s";
            volume = "m3";
            thickness = "mm";
            molar_enthalpy = "kJ/kmol";
            molar_entropy = "kJ/[kmol.K]";
            velocity = "m/s";
            foulingfactor = "K.m2/W";

            pdp_boilingPointTemperature = "C";
            pdp_meltingTemperature = "C";
            spmp_activity = "Pa";
            spmp_activityCoefficient = "-";
            spmp_compressibility = "Pa-1";
            spmp_compressibilityFactor = "-";
            spmp_density = "kg/m3";
            spmp_enthalpy = "kJ/kg";
            spmp_entropy = "kJ/[kg.K]";
            spmp_excessEnthalpy = "kJ/kg";
            spmp_excessEntropy = "kJ/[kg.K]";
            spmp_fugacity = "Pa";
            spmp_fugacityCoefficient = "-";
            spmp_heatCapacityCp = "kJ/[kg.K]";
            spmp_heatCapacityCv = "kJ/[kg.K]";
            spmp_jouleThomsonCoefficient = "K/Pa";
            spmp_logFugacityCoefficient = "-";
            spmp_massflow = "kg/h";
            spmp_massfraction = "-";
            spmp_molarflow = "m3/d @ BR";
            spmp_molarfraction = "-";
            spmp_molecularWeight = "kg/kmol";
            spmp_pressure = "kgf/cm2_a";
            spmp_speedOfSound = "m/s";
            spmp_temperature = "C";
            spmp_thermalConductivity = "W/[m.K]";
            spmp_viscosity = "cP";
            spmp_volumetricFlow = "m3/h";
            spmp_cinematic_viscosity = "cSt";
            tdp_idealGasHeatCapacity = "kJ/[kg.K]";
            tdp_surfaceTension = "N/m";
            tdp_thermalConductivityOfLiquid = "W/[m.K]";
            tdp_thermalConductivityOfVapor = "W/[m.K]";
            tdp_vaporPressure = "kgf/cm2_a";
            tdp_viscosityOfLiquid = "cP";
            tdp_viscosityOfVapor = "cP";
            tpmp_kvalue = "-";
            tpmp_logKvalue = "-";
            tpmp_surfaceTension = "N/m";
            spmp_heatflow = "kW";
            spmp_head = "m";
            spmp_deltaP = "kgf/cm2";
            spmp_deltaT = "C.";
        }
    }

    [Serializable]
    public class  UnidadesSI_Deriv2 : Unidades
    {
        public UnidadesSI_Deriv2()
        {
            nome = "Personalizado2SC";

            accel = "m2/s";
            area = "m2";
            diameter = "mm";
            distance = "m";
            force = "N";
            heat_transf_coeff = "W/[m2.K]";
            mass_conc = "kg/m3";
            molar_conc = "kmol/m3";
            molar_volume = "m3/kmol";
            reac_rate = "kmol.[m3.s]";
            spec_vol = "m3/kg";
            time = "s";
            volume = "m3";
            thickness = "mm";
            molar_enthalpy = "kJ/kmol";
            molar_entropy = "kJ/[kmol.K]";
            velocity = "m/s";
            foulingfactor = "K.m2/W";

            pdp_boilingPointTemperature = "C";
            pdp_meltingTemperature = "C";
            spmp_activity = "Pa";
            spmp_activityCoefficient = "-";
            spmp_compressibility = "Pa-1";
            spmp_compressibilityFactor = "-";
            spmp_density = "kg/m3";
            spmp_enthalpy = "kJ/kg";
            spmp_entropy = "kJ/[kg.K]";
            spmp_excessEnthalpy = "kJ/kg";
            spmp_excessEntropy = "kJ/[kg.K]";
            spmp_fugacity = "Pa";
            spmp_fugacityCoefficient = "-";
            spmp_heatCapacityCp = "kJ/[kg.K]";
            spmp_heatCapacityCv = "kJ/[kg.K]";
            spmp_jouleThomsonCoefficient = "K/Pa";
            spmp_logFugacityCoefficient = "-";
            spmp_massflow = "kg/h";
            spmp_massfraction = "-";
            spmp_molarflow = "m3/d @ SC";
            spmp_molarfraction = "-";
            spmp_molecularWeight = "kg/kmol";
            spmp_pressure = "kgf/cm2_a";
            spmp_speedOfSound = "m/s";
            spmp_temperature = "C";
            spmp_thermalConductivity = "W/[m.K]";
            spmp_viscosity = "cP";
            spmp_volumetricFlow = "m3/h";
            spmp_cinematic_viscosity = "cSt";
            tdp_idealGasHeatCapacity = "kJ/[kg.K]";
            tdp_surfaceTension = "N/m";
            tdp_thermalConductivityOfLiquid = "W/[m.K]";
            tdp_thermalConductivityOfVapor = "W/[m.K]";
            tdp_vaporPressure = "kgf/cm2_a";
            tdp_viscosityOfLiquid = "cP";
            tdp_viscosityOfVapor = "cP";
            tpmp_kvalue = "-";
            tpmp_logKvalue = "-";
            tpmp_surfaceTension = "N/m";
            spmp_heatflow = "kW";
            spmp_head = "m";
            spmp_deltaP = "kgf/cm2";
            spmp_deltaT = "C.";
        }
    }

    [Serializable]
    public class  UnidadesSI_Deriv3 : Unidades
    {
        public UnidadesSI_Deriv3()
        {
            
            nome = "Personalizado3CNTP";

            accel = "m/s2";
            area = "m2";
            diameter = "mm";
            distance = "m";
            force = "N";
            heat_transf_coeff = "W/[m2.K]";
            mass_conc = "kg/m3";
            molar_conc = "kmol/m3";
            molar_volume = "m3kmol";
            reac_rate = "kmol.[m3.s]";

            spec_vol = "m3/kg";
            time = "s";
            volume = "m3";
            thickness = "mm";
            molar_enthalpy = "kJ/kmol";
            molar_entropy = "kJ/[kmol.K]";
            velocity = "m/s";
            foulingfactor = "K.m2/W";

            pdp_boilingPointTemperature = "C";
            pdp_meltingTemperature = "C";
            spmp_activity = "Pa";
            spmp_activityCoefficient = "-";
            spmp_compressibility = "Pa-1";
            spmp_compressibilityFactor = "-";
            spmp_density = "kg/m3";
            spmp_enthalpy = "kJ/kg";
            spmp_entropy = "kJ/[kg.K]";
            spmp_excessEnthalpy = "kJ/kg";
            spmp_excessEntropy = "kJ/[kg.K]";
            spmp_fugacity = "Pa";
            spmp_fugacityCoefficient = "-";
            spmp_heatCapacityCp = "kJ/[kg.K]";
            spmp_heatCapacityCv = "kJ/[kg.K]";
            spmp_jouleThomsonCoefficient = "K/Pa";
            spmp_logFugacityCoefficient = "-";
            spmp_massflow = "kg/h";
            spmp_massfraction = "-";
            spmp_molarflow = "m3/d @ CNTP";
            spmp_molarfraction = "-";
            spmp_molecularWeight = "kg/kmol";
            spmp_pressure = "kgf/cm2_a";
            spmp_speedOfSound = "m/s";
            spmp_temperature = "C";
            spmp_thermalConductivity = "W/[m.K]";
            spmp_viscosity = "cP";
            spmp_volumetricFlow = "m3/h";
            spmp_cinematic_viscosity = "cSt";
            tdp_idealGasHeatCapacity = "kJ/[kg.K]";
            tdp_surfaceTension = "N/m";
            tdp_thermalConductivityOfLiquid = "W/[m.K]";
            tdp_thermalConductivityOfVapor = "W/[m.K]";
            tdp_vaporPressure = "kgf/cm2_a";
            tdp_viscosityOfLiquid = "cP";
            tdp_viscosityOfVapor = "cP";
            tpmp_kvalue = "-";
            tpmp_logKvalue = "-";
            tpmp_surfaceTension = "N/m";
            spmp_heatflow = "kW";
            spmp_head = "m";
            spmp_deltaP = "kgf/cm2";
            spmp_deltaT = "C.";
        }
    }

    [Serializable]
    public class  UnidadesSI_Deriv4 : Unidades
    {
        public UnidadesSI_Deriv4()
        {
            
            nome = "Personalizado4";

            accel = "m/s2";
            area = "m2";
            diameter = "mm";
            distance = "m";
            force = "N";
            heat_transf_coeff = "W/[m2.K]";
            mass_conc = "kg/m3";
            molar_conc = "kmol/m3";
            molar_volume = "m3kmol";
            reac_rate = "kmol.[m3.s]";
            spec_vol = "m3/kg";
            time = "s";
            volume = "m3";
            thickness = "mm";
            molar_enthalpy = "kJ/kmol";
            molar_entropy = "kJ/[kmol.K]";
            velocity = "m/s";
            foulingfactor = "K.m2/W";

            pdp_boilingPointTemperature = "C";
            pdp_meltingTemperature = "C";
            spmp_activity = "Pa";
            spmp_activityCoefficient = "-";
            spmp_compressibility = "Pa-1";
            spmp_compressibilityFactor = "-";
            spmp_density = "kg/m3";
            spmp_enthalpy = "kJ/kg";
            spmp_entropy = "kJ/[kg.K]";
            spmp_excessEnthalpy = "kJ/kg";
            spmp_excessEntropy = "kJ/[kg.K]";
            spmp_fugacity = "Pa";
            spmp_fugacityCoefficient = "-";
            spmp_heatCapacityCp = "kJ/[kg.K]";
            spmp_heatCapacityCv = "kJ/[kg.K]";
            spmp_jouleThomsonCoefficient = "K/Pa";
            spmp_logFugacityCoefficient = "-";
            spmp_massflow = "kg/d";
            spmp_massfraction = "-";
            spmp_molarflow = "m3/d @ SC";
            spmp_molarfraction = "-";
            spmp_molecularWeight = "kg/kmol";
            spmp_pressure = "kPa";
            spmp_speedOfSound = "m/s";
            spmp_temperature = "C";
            spmp_thermalConductivity = "W/[m.K]";
            spmp_viscosity = "cP";
            spmp_volumetricFlow = "m3/d";
            spmp_cinematic_viscosity = "cSt";
            tdp_idealGasHeatCapacity = "kJ/[kg.K]";
            tdp_surfaceTension = "N/m";
            tdp_thermalConductivityOfLiquid = "W/[m.K]";
            tdp_thermalConductivityOfVapor = "W/[m.K]";
            tdp_vaporPressure = "kPa";
            tdp_viscosityOfLiquid = "cP";
            tdp_viscosityOfVapor = "cP";
            tpmp_kvalue = "-";
            tpmp_logKvalue = "-";
            tpmp_surfaceTension = "N/m";
            spmp_heatflow = "kJ/d";
            spmp_head = "m";
            spmp_deltaP = "kgf/cm2";
            spmp_deltaT = "C.";
        }
    }


    [Serializable]
    public class  UnidadesINGLES : Unidades
    {
        public UnidadesINGLES()
        {
            nome = "SistemaIngls";

            accel = "ft/s2";
            area = "ft2";
            diameter = "in";
            distance = "ft";
            force = "lbf";
            heat_transf_coeff = "BTU/[ft2.h.R]";
            mass_conc = "lbm/ft3";
            molar_conc = "lbmol/ft3";
            molar_volume = "ft3/lbmol";
            reac_rate = "lbmol.[ft3.h]";
            spec_vol = "ft3/lbm";
            time = "h";
            volume = "ft3";
            thickness = "in";
            molar_enthalpy = "BTU/lbmol";
            molar_entropy = "BTU/[lbmol.R]";
            velocity = "ft/s";
            foulingfactor = "ft2.h.F/BTU";

            pdp_boilingPointTemperature = "R";
            pdp_meltingTemperature = "R";
            spmp_activity = "lbf/ft2";
            spmp_activityCoefficient = "-";
            spmp_compressibility = "ft2/lbf";
            spmp_compressibilityFactor = "-";
            spmp_density = "lbm/ft3";
            spmp_enthalpy = "BTU/lbm";
            spmp_entropy = "BTU/[lbm.R]";
            spmp_excessEnthalpy = "BTU/lbm";
            spmp_excessEntropy = "BTU/[lbm.R]";
            spmp_fugacity = "lbf/ft2";
            spmp_fugacityCoefficient = "-";
            spmp_heatCapacityCp = "BTU/[lbm.R]";
            spmp_heatCapacityCv = "BTU/[lbm.R]";
            spmp_jouleThomsonCoefficient = "R/[lbf/ft2]";
            spmp_logFugacityCoefficient = "-";
            spmp_massflow = "lbm/h";
            spmp_massfraction = "-";
            spmp_molarflow = "lbmol/h";
            spmp_molarfraction = "-";
            spmp_molecularWeight = "lbm/lbmol";
            spmp_pressure = "lbf/ft2";
            spmp_speedOfSound = "ft/s";
            spmp_temperature = "R";
            spmp_thermalConductivity = "BTU/[ft.h.R]";
            spmp_viscosity = "lbm/[ft.h]";
            tdp_idealGasHeatCapacity = "BTU/[lbm.R]";
            tdp_surfaceTension = "lbf/in";
            tdp_thermalConductivityOfLiquid = "BTU/[ft.h.R]";
            tdp_thermalConductivityOfVapor = "BTU/[ft.h.R]";
            tdp_vaporPressure = "lbf/ft2";
            tdp_viscosityOfLiquid = "lbm/[ft.h]";
            tdp_viscosityOfVapor = "lbm/[ft.h]";
            tpmp_kvalue = "-";
            tpmp_logKvalue = "-";
            tpmp_surfaceTension = "lbf/in";
            spmp_volumetricFlow = "ft3/s";
            spmp_cinematic_viscosity = "ft2/s";
            spmp_heatflow = "BTU/h";
            spmp_head = "ft";
            spmp_deltaP = "lbf/ft2";
            spmp_deltaT = "R.";
        }
    }

    [Serializable]
    public class  UnidadesCGS : Unidades
    {
        public UnidadesCGS()
        {
            nome = "SistemaCGS";

            accel = "cm/s2";
            area = "cm2";
            diameter = "mm";
            distance = "cm";
            force = "dyn";
            heat_transf_coeff = "cal/[cm2.s.C]";
            mass_conc = "g/cm3";
            molar_conc = "mol/cm3";
            molar_volume = "cm3/mol";
            reac_rate = "mol.[cm3.s]";
            spec_vol = "cm3/g";
            time = "s";
            volume = "cm3";
            thickness = "cm";
            molar_enthalpy = "cal/mol";
            molar_entropy = "cal/[mol.C]";
            velocity = "cm/s";
            foulingfactor = "C.cm2.s/cal";

            pdp_boilingPointTemperature = "C";
            pdp_meltingTemperature = "C";
            spmp_activity = "atm";
            spmp_activityCoefficient = "-";
            spmp_compressibility = "atm-1";
            spmp_compressibilityFactor = "-";
            spmp_density = "g/cm3";
            spmp_enthalpy = "cal/g";
            spmp_entropy = "cal/[g.C]";
            spmp_excessEnthalpy = "cal/g";
            spmp_excessEntropy = "cal/[g.C]";
            spmp_fugacity = "atm";
            spmp_fugacityCoefficient = "-";
            spmp_heatCapacityCp = "cal/[g.C]";
            spmp_heatCapacityCv = "cal/[g.C]";
            spmp_jouleThomsonCoefficient = "C/atm";
            spmp_logFugacityCoefficient = "-";
            spmp_massflow = "g/s";
            spmp_massfraction = "-";
            spmp_molarflow = "mol/s";
            spmp_molarfraction = "-";
            spmp_molecularWeight = "g/mol";
            spmp_pressure = "atm";
            spmp_speedOfSound = "cm/s";
            spmp_temperature = "C";
            spmp_thermalConductivity = "cal/[cm.s.C]";
            spmp_viscosity = "cP";
            tdp_idealGasHeatCapacity = "cal/[g.C]";
            tdp_surfaceTension = "dyn/cm";
            tdp_thermalConductivityOfLiquid = "cal/[cm.s.C]";
            tdp_thermalConductivityOfVapor = "cal/[cm.s.C]";
            tdp_vaporPressure = "atm";
            tdp_viscosityOfLiquid = "cP";
            tdp_viscosityOfVapor = "cP";
            tpmp_kvalue = "-";
            tpmp_logKvalue = "-";
            tpmp_surfaceTension = "dyn/cm2";
            spmp_volumetricFlow = "cm3/s";
            spmp_cinematic_viscosity = "cSt";
            spmp_heatflow = "kcal/h";
            spmp_head = "m";
            spmp_deltaT = "C.";
            spmp_deltaP = "atm";

        }
    }

    [Serializable]
    public class  Conversor
    {
        public double ConverterParaSI(string  unidade , double valor )
        {

            switch(unidade)
            {
                case "m/s":
                    return valor;
                case "cm/s":
                    return valor / 100;
                case "mm/s":
                    return valor / 1000;
                case "km/h":
                    return valor / 3.6;
                case "ft/h":
                    return valor / 11811;
                case "ft/min":
                    return valor / 196.85;
                case "ft/s":
                    return valor / 3.28084;
                case "in/s":
                    return valor / 39.3701;

                case "kPa":
                    return valor / 0.001;
                case "ftH2O":
                    return valor / 0.000334;
                case "inH2O":
                    return valor / 0.00401463;
                case "inHg":
                    return valor / 0.000295301;
                case "lbf/ft2":
                    return valor / 0.0208854;
                case "mbar":
                    return valor / 0.01;
                case "mH2O":
                    return valor / 0.000101972;
                case "mmH2O":
                    return valor / 0.101972;
                case "mmHg":
                    return valor / 0.00750064;
                case "MPa":
                    return valor / 0.000001;
                case "psi":
                    return valor / 0.000145038;
                case "bar":
                    return valor * 100000;
                case "kPag":
                    return (valor + 101.325) * 1000;
                case "barg":
                    return (valor + 1) * 100000;
                case "kgf/cm2g":
                    return (valor + 1.033) * 101325 / 1.033;
                case "psig":
                    return (valor + 14.696) * 6894.8;

                case "kg/d":
                    return valor / 60 / 60 / 24;
                case "kg/min":
                    return valor / 60;
                case "lb/h":
                    return valor / 7936.64;
                case "lb/min":
                    return valor / 132.277;
                case "lb/s":
                    return 2.20462;

                case "mol/h":
                    return valor / 3600;
                case "mol/d":
                    return valor / 3600 / 24;
                case "kmol/s":
                    return valor * 1000;
                case "kmol/h":
                    return valor * 1000 / 3600;
                case "kmol/d":
                    return valor * 1000 / 3600 / 24;

                case "bbl/h":
                    return valor / 22643.3;
                case "bbl/d":
                    return valor / 543440;
                case "ft3/min":
                    return valor / 35.3147 / 60;
                case "ft3/s":
                    return valor / 35.3147;
                case "gal[UK]/h":
                    return valor / 791889;
                case "gal[UK]/s":
                    return valor / 219.969;
                case "gal[US]/h":
                    return valor / 951019;
                case "gal[US]/min":
                    return valor / 15850.3;
                case "L/h":
                    return valor / 3600000.0;
                case "L/min":
                    return valor / 60000;
                case "L/s":
                    return valor / 1000;
                case "m3/d":
                    return valor / 3600 / 24;

                case "BTU/h":
                    return valor / 3412.14;
                case "BTU/s":
                    return valor / 0.947817;
                case "cal/s":
                    return valor / 238.846;
                case "HP":
                    return valor / 1.35962;
                case "kcal/h":
                    return valor / 859.845;
                case "kJ/h":
                    return valor / 3600;
                case "kJ/d":
                    return valor / 3600 / 24;
                case "MW":
                    return valor / 0.001;
                case "W":
                    return valor / 1000;

                case "BTU/lb":
                    return valor / 0.429923;
                case "cal/g":
                    return valor / 0.238846;
                case "kcal/kg":
                    return valor / 0.238846;

                case "kJ/kmol":
                    return valor;
                case "cal/mol":
                    return valor * 0.0041868 * 1000;
                case "BTU/lbmol":
                    return valor * 1.05506 * 1000;
                case "kJ/[kmol.K]":
                    return valor * 1;
                case "cal/[mol.°C]":
                    return valor * 0.0041868 * 1000;
                case "cal/[mol.C]":
                    return valor * 0.0041868 * 1000;
                case "BTU/[lbmol.R]":
                    return valor * 1.05506 * 1000;

                case "K.m2/W":      //'fouling factor
                    return valor;
                case "C.cm2.s/cal":
                    return valor * 0.000023885;
                case "ft2.h.F/BTU":
                    return valor * 0.17611;


                case "m2"  :        //'area
                    return valor;
                case "cm2":
                    return valor / 10000.0;
                case "ft2":
                    return valor / 10.7639;
                case "h" :         //'tempo
                    return valor / 3600;
                case "s":
                    return valor;
                case "min.":
                    return valor / 60;
                case "ft3" :                             //'volume
                    return valor / 35.3147;
                case "m3":
                    return valor;
                case "cm3":
                    return valor / 1000000.0;
                case "L":
                    return valor / 1000.0;
                case "cm3/mol" :                         //'volume molar'
                    return valor / 1000.0;
                case "m3/kmol":
                    return valor;
                case "m3/mol":
                    return valor * 1000;
                case "ft3/lbmol":
                    return valor / 35.3147 / 1000;
                case "mm" :                              //'comprimento'
                    return valor / 1000;
                case "in.":
                case "in":
                    return valor / 39.3701;
                case "dyn"    :                          //'força
                    return valor / 100000;
                case "N":
                    return valor;
                case "lbf":
                    return valor / 0.224809;
                case "mol/L"  :                          //'conc molar
                    return valor;
                case "kmol/m3":
                    return valor;
                case "mol/cm3":
                    return valor * 1000000.0 / 1000;
                case "mol/mL":
                    return valor * 1000000.0 / 1000;
                case "lbmol/ft3":
                    return valor * 35.3147 * 1000;
                case "g/L"      :                        //'conc mássica
                    return valor;
                case "kg/m3":
                    return valor;
                case "g/cm3":
                    return valor * 1000000.0 / 1000;
                case "g/mL":
                    return valor * 1000000.0 / 1000;
                case "m2/s"     :                         //'k.visc
                    return valor;
                case "ft/s2":
                    return valor / 3.28084;
                case "cm2/s":
                    return valor / 10000.0;
                case "W/[m2.K]"   :                           //'HTC
                    return valor;
                case "BTU/[ft2.h.R]":
                    return valor / 0.17611;
                case "cal/[cm.s.°C]":
                    return valor / 0.0000238846;
                case "cal/[cm.s.C]":
                    return valor / 0.0000238846;
                case "m3/kg"         :                       //'vol especif
                    return valor;
                case "ft3/lbm":
                    return valor * 0.062428;
                case "cm3/g":
                    return valor / 1000;
                case "kmol/[m3.s]":
                    return valor * 1000   ;                         //'taxa reacao
                case "kmol/[m3.min.]":
                    return valor / 60 * 1000;
                case "kmol/[m3.h]":
                    return valor / 3600 * 1000;
                case "mol/[m3.s]":
                    return valor;
                case "mol/[m3.min.]":
                    return valor / 60;
                case "mol/[m3.h]":
                    return valor / 3600;
                case "mol/[L.s]":
                    return valor / 1000;
                case "mol/[L.min.]":
                    return valor / 60 / 1000;
                case "mol/[L.h]":
                    return valor / 3600 / 1000;
                case "mol/[cm3.s]":
                    return valor * 1000000.0;
                case "mol/[cm3.min.]":
                    return valor / 60 * 1000000.0;
                case "mol/[cm3.h]":
                    return valor / 3600 * 1000000.0;
                case "lbmol.[ft3.h]":
                    return valor / 3600 * 35.3147 * 1000;
                case "°C"  :                             //'temperatura e demais
                    return valor + 273.15;
                case "C"   :                            //'temperatura e demais
                    return valor + 273.15;
                case "°C.":
                    return valor;
                case "C.":
                    return valor;
                case "atm":
                    return valor * 101325;
                case "g/s":
                    return valor / 1000;
                case "mol/s":
                    return valor;
                case "kmol/s":
                    return valor * 1000;
                case "cal/g":
                    return valor / 0.238846;
                case "g/cm3":
                    return valor * 1000;
                case "dyn/cm":
                    return valor * 0.001;
                case "dyn/cm2":
                    return valor * 0.001;
                case "cal/[cm.s.°C]":
                    return valor / 0.00238846;
                case "cal/[cm.s.C]":
                    return valor / 0.00238846;
                case "cm3/s":
                    return valor * 0.000001;
                case "cal/[g.°C]":
                    return valor / 0.238846;
                case "cal/[g.C]":
                    return valor / 0.238846;
                case "cSt":
                    return valor / 1000000.0;
                case "mm2/s":
                    return valor / 1000000.0;
                case "Pa.s":
                    return valor;
                case "cP":
                    return valor / 1000;
                case "m":
                    return valor;
                case "R":
                    return valor / 1.8;
                case "R.":
                    return valor / 1.8;
                case "lbm/h":
                    return valor / 7936.64;
                case "lbmol/h":
                    return valor * 453.59237 / 3600;
                case "BTU/lbm":
                    return valor / 0.429923;
                case "lbm/ft3":
                    return valor / 0.062428;
                case "lbf/in":
                    return valor / 0.00571015;
                case "BTU/[ft.h.R]":
                    return valor / 0.577789;
                case "ft3/s":
                    return valor / 35.3147;
                case "BTU/[lbm.R]":
                    return valor / 0.238846;
                case "ft2/s":
                    return valor / 10.7639;
                case "lbm/[ft.s]":
                    return valor / 0.671969;
                case "BTU/h":
                    return valor / 3412.14;
                case "ft":
                    return valor / 3.28084;
                    //'Personalizados
                case "kgf/cm2_a":
                    return valor * 101325 / 1.033;
                case "kgf/cm2":
                    return valor * 101325 / 1.033;
                case "kgf/cm2_g":
                    return (valor + 1.033) * 101325 / 1.033;
                case "kg/h":
                    return valor / 3600;
                case "kg/d":
                    return valor / 3600 / 24;
                case "m3/h":
                    return valor / 3600;
                case "m3/d":
                    return valor / 3600 / 24;
                case "m3/d @ BR":
                    return valor / (24.055 * 3600 * 24 / 1000);
                case "m3/d @ CNTP":
                    return valor / (22.71 * 3600 * 24 / 1000);
                case "m3/d @ NC":
                    return valor / (22.71 * 3600 * 24 / 1000);
                case "m3/d @ SC":
                    return valor / (23.69 * 3600 * 24 / 1000);
                case "°F":
                    return (valor - 32) * 5 / 9 + 273.15;
                case "°F.":
                    return valor / 1.8;
                case "F":
                    return (valor - 32) * 5 / 9 + 273.15;
                case "F.":
                    return valor / 1.8;
                case "cm":
                    return valor / 100;
                case "cal/[mol.°C]":
                    return valor * 238.846 / 1000;
                case "BTU/[lbmol.R]":
                    return valor * 1.8 * 0.947817;
            default:
                    return valor;
            }
        }

        public double ConverterDoSI(string unidade, double valor)
        {
            switch(unidade)
            {
                case "m/s":
                    return valor;
                case "cm/s":
                    return valor * 100;
                case "mm/s":
                    return valor * 1000;
                case "km/h":
                    return valor * 3.6;
                case "ft/h":
                    return valor * 11811;
                case "ft/min":
                    return valor * 196.85;
                case "ft/s":
                    return valor * 3.28084;
                case "in/s":
                    return valor * 39.3701;

                case "kPa":
                    return valor * 0.001;
                case "ftH2O":
                    return valor * 0.000334;
                case "inH2O":
                    return valor * 0.00401463;
                case "inHg":
                    return valor * 0.000295301;
                case "lbf/ft2":
                    return valor * 0.0208854;
                case "mbar":
                    return valor * 0.01;
                case "mH2O":
                    return valor * 0.000101972;
                case "mmH2O":
                    return valor * 0.101972;
                case "mmHg":
                    return valor * 0.00750064;
                case "MPa":
                    return valor * 0.000001;
                case "psi":
                    return valor * 0.000145038;
                case "bar":
                    return valor / 100000;
                case "kPag":
                    return (valor - 101325) / 1000;
                case "barg":
                    return (valor - 101325) / 100000;
                case "kgf/cm2g":
                    return (valor - 101325) / 101325 * 1.033;
                case "psig":
                    return (valor - 101325) * 0.000145038;

                case "kg/d":
                    return valor * 60 * 60 * 24;
                case "kg/min":
                    return valor * 60;
                case "lb/h":
                    return valor * 7936.64;
                case "lb/min":
                    return valor * 132.277;
                case "lb/s":
                    return 2.20462;

                case "bbl/h":
                    return valor * 22643.3;
                case "bbl/d":
                    return valor * 543440;
                case "ft3/min":
                    return valor * 35.3147 * 60;
                case "ft3/s":
                    return valor * 35.3147;
                case "gal[UK]/h":
                    return valor * 791889;
                case "gal[UK]/s":
                    return valor * 219.969;
                case "gal[US]/h":
                    return valor * 951019;
                case "gal[US]/min":
                    return valor * 15850.3;
                case "L/h":
                    return valor * 3600000.0;
                case "L/min":
                    return valor * 60000;
                case "L/s":
                    return valor * 1000;
                case "m3/d":
                    return valor * 3600 * 24;

                case "mol/h":
                    return valor * 3600;
                case "mol/d":
                    return valor * 3600 * 24;
                case "kmol/s":
                    return valor / 1000;
                case "kmol/h":
                    return valor / 1000 * 3600;
                case "kmol/d":
                    return valor / 1000 * 3600 * 24;

                case "BTU/h":
                    return valor * 3412.14;
                case "BTU/s":
                    return valor * 0.947817;
                case "cal/s":
                    return valor * 238.846;
                case "HP":
                    return valor * 1.35962;
                case "kcal/h":
                    return valor * 859.845;
                case "kJ/h":
                    return valor * 3600;
                case "kJ/d":
                    return valor * 3600 * 24;
                case "MW":
                    return valor * 0.001;
                case "W":
                    return valor * 1000;

                case "BTU/lb":
                    return valor * 0.429923;
                case "cal/g":
                    return valor * 0.238846;
                case "kcal/kg":
                    return valor * 0.238846;

                case "kJ/kmol":
                    return valor;
                case "cal/mol":
                    return valor / 0.0041868 / 1000;
                case "BTU/lbmol":
                    return valor / 1.05506 / 1000;
                case "kJ/[kmol.K]":
                    return valor;
                case "cal/[mol.°C]":
                    return valor / 0.0041868 / 1000;
                case "cal/[mol.C]":
                    return valor / 0.0041868 / 1000;
                case "BTU/[lbmol.R]":
                    return valor / 1.05506 / 1000;

                case "K.m2/W" :                          //'fouling factor
                    return valor;
                case "C.cm2.s/cal":
                    return valor / 0.000023885;
                case "ft2.h.F/BTU":
                    return valor / 0.17611;

                case "m2" :                              //'area
                    return valor;
                case "cm2":
                    return valor * 10000.0;
                case "ft2":
                    return valor * 10.7639;
                case "h"  :                              //'tempo
                    return valor * 3600;
                case "s":
                    return valor;
                case "min.":
                    return valor * 60;
                case "ft3":                              //'volume
                    return valor * 35.3147;
                case "m3":
                    return valor;
                case "cm3":
                    return valor * 1000000.0;
                case "L":
                    return valor * 1000.0;
                case "cm3/mol" :                         //'volume molar'
                    return valor * 1000.0;
                case "m3/kmol":
                    return valor;
                case "m3/mol":
                    return valor / 1000;
                case "ft3/lbmol":
                    return valor * 35.3147 * 1000;
                case "mm" :                              //'comprimento'
                    return valor * 1000;
                case "in.":
                case "in":
                    return valor * 39.3701;
                case "dyn":                              //'força
                    return valor * 100000;
                case "N":
                    return valor;
                case "lbf":
                    return valor * 0.224809;
                case "mol/L" :                           //'conc molar
                    return valor;
                case "kmol/m3":
                    return valor;
                case "mol/cm3":
                    return valor / 1000000.0 * 1000;
                case "mol/mL":
                    return valor / 1000000.0 * 1000;
                case "lbmol/ft3":
                    return valor * 35.3147 * 1000;
                case "g/L":                              //'conc mássica
                    return valor;
                case "kg/m3":
                    return valor;
                case "g/cm3":
                    return valor / 1000000.0 * 1000;
                case "g/mL":
                    return valor / 1000000.0 * 1000;
                case "lbm/ft3":
                    return valor * 0.062428;
                case "m2/s" :                             //'k.visc
                    return valor;
                case "ft/s2":
                    return valor * 3.28084;
                case "cm2/s":
                    return valor * 10000.0;
                case "W/[m2.K]"  :                            //'HTC
                    return valor;
                case "BTU/[ft2.h.R]":
                    return valor * 0.17611;
                case "cal/[cm.s.°C]":
                    return valor * 0.0000238846;
                case "cal/[cm.s.C]":
                    return valor * 0.0000238846;
                case "m3/kg":                               // 'vol especif
                    return valor;
                case "ft3/lbm":
                    return valor / 0.062428;
                case "cm3/g":
                    return valor * 1000;
                case "kmol/[m3.s]":
                    return valor / 1000     ;                       //'taxa reacao
                case "kmol/[m3.min.]":
                    return valor * 60 / 1000;
                case "kmol/[m3.h]":
                    return valor * 3600 / 1000;
                case "mol/[m3.s]":
                    return valor
                case "mol/[m3.min.]":
                    return valor * 60;
                case "mol/[m3.h]":
                    return valor * 3600;
                case "mol/[L.s]":
                    return valor * 1000;
                case "mol/[L.min.]":
                    return valor * 60 * 1000;
                case "mol/[L.h]":
                    return valor * 3600 * 1000;
                case "mol/[cm3.s]":
                    return valor / 1000000.0;
                case "mol/[cm3.min.]":
                    return valor * 60 / 1000000.0;
                case "mol/[cm3.h]":
                    return valor * 3600 / 1000000.0;
                case "lbmol.[ft3.h]":
                    return valor * 3600 / 35.3147 / 1000;
                case "°C"      :                         //'temperatura e demais
                    return valor - 273.15;
                case "C"     :                          //'temperatura e demais
                    return valor - 273.15;
                case "°C.":
                    return valor;
                case "C.":
                    return valor;
                case "atm":
                    return valor / 101325;
                case "g/s":
                    return valor * 1000;
                case "mol/s":
                    return valor;
                case "cal/g":
                    return valor * 0.238846;
                case "g/cm3":
                    return valor / 1000;
                case "dyn/cm":
                    return valor / 0.001;
                case "dyn/cm2":
                    return valor / 0.001;
                case "cal/[cm.s.°C]":
                    return valor * 0.00238846;
                case "cal/[cm.s.C]":
                    return valor * 0.00238846;
                case "cm3/s":
                    return valor / 0.000001;
                case "cal/[g.°C]":
                    return valor * 0.238846;
                case "cal/[g.C]":
                    return valor * 0.238846;
                case "cSt":
                    return valor * 1000000.0;
                case "mm2/s":
                    return valor * 1000000.0;
                case "Pa.s":
                    return valor;
                case "cP":
                    return valor * 1000;
                case "kcal/h":
                    return valor * 859.845;
                case "R":
                    return valor * 1.8;
                case "R.":
                    return valor * 1.8;
                case "lbf/ft2":
                    return valor * 0.0208854;
                case "lbm/h":
                    return valor * 7936.64;
                case "lbmol/h":
                    return valor / 453.59237 * 3600;
                case "BTU/lbm":
                    return valor * 0.429923;
                case "lbf/in":
                    return valor * 0.00571015;
                case "BTU/[ft.h.R]":
                    return valor * 0.577789;
                case "ft3/s":
                    return valor * 35.3147;
                case "BTU/[lbm.R]":
                    return valor * 0.238846;
                case "ft2/s":
                    return valor * 10.7639;
                case "lbm/[ft.s]":
                    return valor * 0.671969;
                case "BTU/h":
                    return valor * 3412.14;
                case "ft":
                    return valor * 3.28084;
                    //'Personalizados
                case "kgf/cm2_a":
                    return valor / 101325 * 1.033;
                case "kgf/cm2":
                    return valor / 101325 * 1.033;
                case "kgf/cm2_g":
                    return valor * 1.033 / 101325 - 1.033;
                case "kg/h":
                    return valor * 3600;
                case "kg/d":
                    return valor * 3600 * 24;
                case "m3/h":
                    return valor * 3600;
                case "m3/d":
                    return valor * 3600 * 24;
                case "m3/d @ BR":
                    return valor * (24.055 * 3600 * 24 / 1000);
                case "m3/d @ CNTP":
                    return valor * (22.71 * 3600 * 24 / 1000);
                case "m3/d @ NC":
                    return valor * (22.71 * 3600 * 24 / 1000);
                case "m3/d @ SC":
                    return valor * (23.69 * 3600 * 24 / 1000);
                case "°F":
                    return (valor - 273.15) * 9 / 5 + 32;
                case "°F.":
                    return valor * 1.8;
                case "F":
                    return (valor - 273.15) * 9 / 5 + 32;
                case "F.":
                    return valor * 1.8;
                case "cm":
                    return valor * 100;
                case "cal/[mol.°C]":
                    return valor / 238.846 * 1000;
                case "cal/[mol.C]":
                    return valor / 238.846 * 1000;
                case "BTU/[lbmol.R]":
                    return valor / 1.8 / 0.947817;
                default:
                    return valor;
            }
        }
    }
}